from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *

import doHistogram
import doSummary
import doXYPlot
import doSplom
import doGLM

class MainPlugin:
    def __init__(self,iface):
        self.iface=iface
        return None

    def initGui(self):
        print "init gui"
        self.menu = QMenu("Statistics")
        self.summary = QAction("Summary",self.iface.mainWindow())
        self.splom = QAction("Scatterplot Matrix",self.iface.mainWindow())
        self.histogram = QAction("Histogram",self.iface.mainWindow())
        self.xyPlot = QAction("X-Y plot",self.iface.mainWindow())
        self.lm = QAction("Linear regression",self.iface.mainWindow())

        self.savePlot = QAction("Save Plot to EPS file",self.iface.mainWindow())

        QObject.connect(self.histogram, SIGNAL("triggered()"), self.doHistogram)
        QObject.connect(self.summary, SIGNAL("triggered()"), self.doSummary)
        QObject.connect(self.splom, SIGNAL("triggered()"), self.doSplom)
        QObject.connect(self.xyPlot, SIGNAL("triggered()"), self.doXYPlot)
        QObject.connect(self.lm, SIGNAL("triggered()"), self.doGLM)
        QObject.connect(self.savePlot, SIGNAL("triggered()"),self.doSavePlot)
        
        self.menu.addActions([self.summary, self.histogram, self.splom, self.xyPlot, self.lm])
        self.menu.addSeparator()
        self.menu.addAction(self.savePlot)
        menuBar = self.iface.mainWindow().menuBar()
        menuBar.addMenu(self.menu)

    def doSummary(self):
        d = doSummary.Dialog(self.iface)
        d.exec_()

    def doHistogram(self):
        d = doHistogram.Dialog(self.iface)
        d.exec_()

    def doXYPlot(self):
        d = doXYPlot.Dialog(self.iface)
        d.exec_()

    def doSplom(self):
        d = doSplom.Dialog(self.iface)
        d.exec_()

    def doGLM(self):
        d = doGLM.Dialog(self.iface)
        d.exec_()

    def doSavePlot(self):
        print "saving plot to EPS file..."
        print "not yet though!"
        
    def unload(self):
        pass
    
